#import "GKCover.h"
#import "AppDelegate.h"
#import "dfhgwhruebvhrheyavenuetyre.h"
#import "dfhgwhruebvhrheyluggagerecorder.h"
#import "dfhgwhruebvhrheyoutwarddelegate.h"
#import "dfhgwhruebvhrheyleatherfreight.h"
#import "dfhgwhruebvhrheycapableintellectual.h"
#import "dfhgwhruebvhrheysecurityinjure.h"
#import <ContactsUI/ContactsUI.h>
#import "dfhgwhruebvhrheyauthoritycatalogue.h"
#import "dfhgwhruebvhrheywarrantfeasibleViewController.h"
#import "dfhgwhruebvhrheyvisualizeterritoryViewController.h"
@interface dfhgwhruebvhrheyvisualizeterritoryViewController ()<CNContactPickerDelegate>
@property (nonatomic, copy) NSString *relationshipOne;
@property (nonatomic, copy) NSString *relationshipTwo;
@property (nonatomic, copy) NSString *relationshipThree;
@property (nonatomic, strong) dfhgwhruebvhrheycapableintellectual *popView;
@property (weak, nonatomic) IBOutlet UIScrollView *scrollView;
@property (weak, nonatomic) IBOutlet dfhgwhruebvhrheysecurityinjure *oneNameSelectView;
@property (weak, nonatomic) IBOutlet dfhgwhruebvhrheysecurityinjure *onePhoneSelectView;
@property (weak, nonatomic) IBOutlet dfhgwhruebvhrheysecurityinjure *oneRelationshipSelectView;
@property (weak, nonatomic) IBOutlet dfhgwhruebvhrheysecurityinjure *twoNameSelectView;
@property (weak, nonatomic) IBOutlet dfhgwhruebvhrheysecurityinjure *twoPhoneSelectView;
@property (weak, nonatomic) IBOutlet dfhgwhruebvhrheysecurityinjure *twoRelationshipSelectView;
@property (weak, nonatomic) IBOutlet dfhgwhruebvhrheysecurityinjure *threeNameSelectView;
@property (weak, nonatomic) IBOutlet dfhgwhruebvhrheysecurityinjure *threePhoneSelectView;
@property (weak, nonatomic) IBOutlet dfhgwhruebvhrheysecurityinjure *threeRelationshipSelectView;
@property (weak, nonatomic) IBOutlet dfhgwhruebvhrheysecurityinjure *fourNameSelectView;
@property (weak, nonatomic) IBOutlet dfhgwhruebvhrheysecurityinjure *fourPhoneSelectView;
@property (weak, nonatomic) IBOutlet dfhgwhruebvhrheysecurityinjure *fourRelationshipSelectView;
@property (weak, nonatomic) IBOutlet dfhgwhruebvhrheysecurityinjure *fiveNameSelectView;
@property (weak, nonatomic) IBOutlet dfhgwhruebvhrheysecurityinjure *fivePhoneSelectView;
@property (weak, nonatomic) IBOutlet dfhgwhruebvhrheysecurityinjure *fiveRelationshipSelectView;
@end
@implementation dfhgwhruebvhrheyvisualizeterritoryViewController {
	NSMutableDictionary *phoneDic;
}
- (dfhgwhruebvhrheycapableintellectual *)popView {
	if(!_popView) {
		_popView = [[NSBundle mainBundle] loadNibNamed:@"dfhgwhruebvhrheycapableintellectual" owner:nil options:nil].firstObject;
	}
	return _popView;
}
- (void)viewDidLoad {
	[super viewDidLoad];
	[self loadUI];
	[self loadPopData];
	[self loadLocalData];
	[dfhgwhruebvhrheyoptionsaving uploadRiskDataByCatchId:@"8" andApplyId:nil withDetailId:nil];
	[dfhgwhruebvhrheyavenuetyre addTracking:emergency_contact_click_time withValue:0 byType:1];
	[dfhgwhruebvhrheyavenuetyre addTracking:emergency_contact_complleted_duration withValue:0 byType:1];
	NSString *identifier = [[NSUserDefaults standardUserDefaults] stringForKey:[NSString stringWithFormat:@"%@_%@", [dfhgwhruebvhrheyoptionsaving getUserData].phone, dhgfywegwygeydwconnectionencounter]];
	if ([identifier isEqualToString:@"auth_job"]) {
		[[NSUserDefaults standardUserDefaults] setObject:@"contact" forKey:[NSString stringWithFormat:@"%@_%@", [dfhgwhruebvhrheyoptionsaving getUserData].phone, dhgfywegwygeydwconnectionencounter]];
	}
}
- (void)loadPopData {
	if (self.popDataModel == nil) {
		[dfhgwhruebvhrheyoptionsaving.keyWindow startLoading];
		__weak typeof(self) weakSelf = self;
		[[dfhgwhruebvhrheyluggagerecorder shareInstance] dhgfywegwygeydwbarrierawait:dhgfywegwygeydwlambbreast path:authPopDataApi isEncrypt:YES withParams:nil success:^(NSURLSessionDataTask * _Nonnull task, NSString * _Nonnull json) {
			[dfhgwhruebvhrheyoptionsaving.keyWindow stopLoading];
			__strong typeof(weakSelf) strongSelf = weakSelf;
			dfhgwhruebvhrheyleatherfreight *popModel = [dfhgwhruebvhrheyleatherfreight yy_modelWithJSON:json];
			strongSelf.popDataModel = popModel;
		} failure:^(NSURLSessionDataTask * _Nonnull task, NSError * _Nonnull error) {
			[dfhgwhruebvhrheyoptionsaving.keyWindow stopLoading];
		}];
	}
}
- (void)loadLocalData {
	if (!self.localModel) {
		NSString *authDataString = [dfhgwhruebvhrheyoptionsaving getDataStringByKey:dhgfywegwygeydwencounterpropose];
		if (authDataString.length) {
			self.localModel = [dfhgwhruebvhrheyauthoritycatalogue yy_modelWithJSON:authDataString];
		}else {
			self.localModel = [[dfhgwhruebvhrheyauthoritycatalogue alloc] init];
		}
	}
	NSLog(@"绑定本地信息");
	[self.oneNameSelectView bindContent:self.localModel.gx_name];
	[self.onePhoneSelectView bindContent:self.localModel.gx_phone];
	[self.oneRelationshipSelectView bindContent:self.localModel.gx_one];
	[self.twoNameSelectView bindContent:self.localModel.gx_name_two];
	[self.twoPhoneSelectView bindContent:self.localModel.gx_phone_two];
	[self.twoRelationshipSelectView bindContent:self.localModel.gx_two];
	[self.threeNameSelectView bindContent:self.localModel.gx_name_three];
	[self.threePhoneSelectView bindContent:self.localModel.gx_phone_three];
	[self.threeRelationshipSelectView bindContent:self.localModel.gx_three];
	[self.fourNameSelectView bindContent:self.localModel.gx_name_four];
	[self.fourPhoneSelectView bindContent:self.localModel.gx_phone_four];
	[self.fourRelationshipSelectView bindContent:self.localModel.gx_four];
	[self.fiveNameSelectView bindContent:self.localModel.gx_name_five];
	[self.fivePhoneSelectView bindContent:self.localModel.gx_phone_five];
	[self.fiveRelationshipSelectView bindContent:self.localModel.gx_five];
}
- (void)loadUI {
	phoneDic = [@{} mutableCopy];
	[self configBackIcon:@"dhgfywegwygeydwcurvereciprocal"];
	[self configRightIcon:@"navigation_right"];
	self.navigationStyle = dhgfywegwygeydwreciprocaltransport;
	self.navigationItem.title = @"Emergency Information";
	AppDelegate *delegate = (AppDelegate *)[[UIApplication sharedApplication] delegate];
	delegate.inBasicAuth = YES;
	__weak typeof(self) weakSelf = self;
	self.oneNameSelectView.tag = 301;
	[self.oneNameSelectView inputTextViewClick:^(dfhgwhruebvhrheysecurityinjure * _Nonnull clickView) {
		__strong typeof(weakSelf) strongSelf = weakSelf;
		[strongSelf showPopViewTag:strongSelf.oneNameSelectView.tag];
	}];
	self.onePhoneSelectView.tag = 302;
	[self.onePhoneSelectView inputTextViewClick:^(dfhgwhruebvhrheysecurityinjure * _Nonnull clickView) {
		__strong typeof(weakSelf) strongSelf = weakSelf;
		[strongSelf showPopViewTag:strongSelf.onePhoneSelectView.tag];
	}];
	self.oneRelationshipSelectView.tag = 303;
	[self.oneRelationshipSelectView inputTextViewClick:^(dfhgwhruebvhrheysecurityinjure * _Nonnull clickView) {
		__strong typeof(weakSelf) strongSelf = weakSelf;
		[strongSelf showPopViewTag:strongSelf.oneRelationshipSelectView.tag];
	}];
	self.twoNameSelectView.tag = 304;
	[self.twoNameSelectView inputTextViewClick:^(dfhgwhruebvhrheysecurityinjure * _Nonnull clickView) {
		__strong typeof(weakSelf) strongSelf = weakSelf;
		[strongSelf showPopViewTag:strongSelf.twoNameSelectView.tag];
	}];
	self.twoPhoneSelectView.tag = 305;
	[self.twoPhoneSelectView inputTextViewClick:^(dfhgwhruebvhrheysecurityinjure * _Nonnull clickView) {
		__strong typeof(weakSelf) strongSelf = weakSelf;
		[strongSelf showPopViewTag:strongSelf.twoPhoneSelectView.tag];
	}];
	self.twoRelationshipSelectView.tag = 306;
	[self.twoRelationshipSelectView inputTextViewClick:^(dfhgwhruebvhrheysecurityinjure * _Nonnull clickView) {
		__strong typeof(weakSelf) strongSelf = weakSelf;
		[strongSelf showPopViewTag:strongSelf.twoRelationshipSelectView.tag];
	}];
	self.threeNameSelectView.tag = 307;
	[self.threeNameSelectView inputTextViewClick:^(dfhgwhruebvhrheysecurityinjure * _Nonnull clickView) {
		__strong typeof(weakSelf) strongSelf = weakSelf;
		[strongSelf showPopViewTag:strongSelf.threeNameSelectView.tag];
	}];
	self.threePhoneSelectView.tag = 308;
	[self.threePhoneSelectView inputTextViewClick:^(dfhgwhruebvhrheysecurityinjure * _Nonnull clickView) {
		__strong typeof(weakSelf) strongSelf = weakSelf;
		[strongSelf showPopViewTag:strongSelf.threePhoneSelectView.tag];
	}];
	self.threeRelationshipSelectView.tag = 309;
	[self.threeRelationshipSelectView inputTextViewClick:^(dfhgwhruebvhrheysecurityinjure * _Nonnull clickView) {
		__strong typeof(weakSelf) strongSelf = weakSelf;
		[strongSelf showPopViewTag:strongSelf.threeRelationshipSelectView.tag];
	}];
	self.fourNameSelectView.tag = 311;
	[self.fourNameSelectView inputTextViewClick:^(dfhgwhruebvhrheysecurityinjure * _Nonnull clickView) {
		__strong typeof(weakSelf) strongSelf = weakSelf;
		[strongSelf showPopViewTag:strongSelf.fourNameSelectView.tag];
	}];
	self.fourPhoneSelectView.tag = 312;
	[self.fourPhoneSelectView inputTextViewClick:^(dfhgwhruebvhrheysecurityinjure * _Nonnull clickView) {
		__strong typeof(weakSelf) strongSelf = weakSelf;
		[strongSelf showPopViewTag:strongSelf.fourPhoneSelectView.tag];
	}];
	self.fourRelationshipSelectView.tag = 313;
	[self.fourRelationshipSelectView inputTextViewClick:^(dfhgwhruebvhrheysecurityinjure * _Nonnull clickView) {
		__strong typeof(weakSelf) strongSelf = weakSelf;
		[strongSelf showPopViewTag:strongSelf.fourRelationshipSelectView.tag];
	}];
	self.fiveNameSelectView.tag = 314;
	[self.fiveNameSelectView inputTextViewClick:^(dfhgwhruebvhrheysecurityinjure * _Nonnull clickView) {
		__strong typeof(weakSelf) strongSelf = weakSelf;
		[strongSelf showPopViewTag:strongSelf.fiveNameSelectView.tag];
	}];
	self.fivePhoneSelectView.tag = 315;
	[self.fivePhoneSelectView inputTextViewClick:^(dfhgwhruebvhrheysecurityinjure * _Nonnull clickView) {
		__strong typeof(weakSelf) strongSelf = weakSelf;
		[strongSelf showPopViewTag:strongSelf.fivePhoneSelectView.tag];
	}];
	self.fiveRelationshipSelectView.tag = 316;
	[self.fiveRelationshipSelectView inputTextViewClick:^(dfhgwhruebvhrheysecurityinjure * _Nonnull clickView) {
		__strong typeof(weakSelf) strongSelf = weakSelf;
		[strongSelf showPopViewTag:strongSelf.fiveRelationshipSelectView.tag];
	}];
}
- (void)openContactList:(int)section {
	CNContactPickerViewController *picker = [[CNContactPickerViewController alloc] init];
	picker.modalPresentationStyle = 0;
	picker.view.tag = section;
	picker.delegate = self;
	[self presentViewController:picker animated:YES completion:nil];
	switch (section) {
		case 1: {
			[dfhgwhruebvhrheyavenuetyre addTracking:emergency_contact_one_phone_duration withValue:0 byType:1];
		}
			break;
		case 2: {
			[dfhgwhruebvhrheyavenuetyre addTracking:emergency_contact_two_phone_duration withValue:0 byType:1];
		}
			break;
		case 3: {
			[dfhgwhruebvhrheyavenuetyre addTracking:emergency_contact_three_phone_duration withValue:0 byType:1];
		}
			break;
		case 4: {
			[dfhgwhruebvhrheyavenuetyre addTracking:emergency_contact_four_phone_duration withValue:0 byType:1];
		}
			break;
		case 5: {
			[dfhgwhruebvhrheyavenuetyre addTracking:emergency_contact_five_phone_duration withValue:0 byType:1];
		}
			break;
		default:
			break;
	}
}
- (void)showRelationshipPopView:(NSUInteger)tag {
	__weak typeof(self) weakSelf = self;
	self.popView.popTitle = @"Relation";
	NSMutableArray *relation1List = [self.popDataModel.relationship.t1 mutableCopy];
	NSMutableArray *relation2List = [self.popDataModel.relationship.t2 mutableCopy];
	if ([relation1List containsObject:self.relationshipTwo]) {
		[relation1List removeObject:self.relationshipTwo];
	}
	if ([relation2List containsObject:self.relationshipOne]) {
		[relation2List removeObject:self.relationshipOne];
	}
	NSArray *dataList = tag == 303 ? relation1List : tag == 306 ? relation2List : self.popDataModel.relationship.t3;
	switch (tag) {
		case 303: {
			[dfhgwhruebvhrheyavenuetyre addTracking:emergency_contact_one_relation_duration withValue:0 byType:1];
		}
			break;
		case 306: {
			[dfhgwhruebvhrheyavenuetyre addTracking:emergency_contact_two_relation_duration withValue:0 byType:1];
		}
			break;
		case 309: {
			[dfhgwhruebvhrheyavenuetyre addTracking:emergency_contact_three_relation_duration withValue:0 byType:1];
		}
			break;
		case 313: {
			[dfhgwhruebvhrheyavenuetyre addTracking:emergency_contact_four_relation_duration withValue:0 byType:1];
		}
			break;
		case 316: {
			[dfhgwhruebvhrheyavenuetyre addTracking:emergency_contact_five_relation_duration withValue:0 byType:1];
		}
			break;
		default:
			break;
	}
	[GKCover coverFrom:[dfhgwhruebvhrheyoptionsaving keyWindow] contentView:self.popView style:GKCoverStyleTranslucent showStyle:GKCoverShowStyleCenter showAnimStyle:GKCoverShowAnimStyleCenter hideAnimStyle:GKCoverHideAnimStyleCenter notClick:YES];
	[self.popView bindRelationShip:dataList andSelect:^(NSString * _Nonnull relation) {
		__strong typeof(weakSelf) strongSelf = weakSelf;
		[GKCover hideCover];
		if (relation.length == 0) {
			return;
		}
		switch (tag) {
			case 303:{
				if ([relation isEqualToString:strongSelf.relationshipThree]) {
					return [dfhgwhruebvhrheyoptionsaving.keyWindow show:@"The Relations that You\'re Chose Can\'t be Repeated With Other，Please Choose Again."];
				}
				strongSelf.relationshipOne = relation;
				strongSelf.localModel.gx_one = relation;
				[strongSelf.oneRelationshipSelectView bindContent:relation];
				[dfhgwhruebvhrheyavenuetyre duartion:emergency_contact_one_relation_duration isCover:YES byType:1];
				[dfhgwhruebvhrheyavenuetyre updateCount:emergency_contact_one_relation_updatecount byType:1];
				if (self.onePhoneSelectView.areadFilled) {
					[dfhgwhruebvhrheyavenuetyre duationTotal:emergency_contact_one_duration withDuration1:emergency_contact_one_phone_duration andDuration2:emergency_contact_one_relation_duration];
				}
			}
				break;
			case 306: {
				if ([relation isEqualToString:strongSelf.relationshipThree]) {
					return [dfhgwhruebvhrheyoptionsaving.keyWindow show:@"The Relations that You\'re Chose Can\'t be Repeated With Other，Please Choose Again."];
				}
				strongSelf.relationshipTwo = relation;
				strongSelf.localModel.gx_two = relation;
				[strongSelf.twoRelationshipSelectView bindContent:relation];
				[dfhgwhruebvhrheyavenuetyre duartion:emergency_contact_two_relation_duration isCover:YES byType:1];
				[dfhgwhruebvhrheyavenuetyre updateCount:emergency_contact_two_relation_updatecount byType:1];
				if (self.twoPhoneSelectView.areadFilled) {
					[dfhgwhruebvhrheyavenuetyre duationTotal:emergency_contact_two_duration withDuration1:emergency_contact_two_phone_duration andDuration2:emergency_contact_two_relation_duration];
				}
			}
				break;
			case 309: {
				if ([relation isEqualToString:self.relationshipOne] || [relation isEqualToString:self.relationshipTwo]) {
					return [dfhgwhruebvhrheyoptionsaving.keyWindow show:@"The Relations that You\'re Chose Can\'t be Repeated With Other，Please Choose Again."];
				}
				strongSelf.relationshipThree = relation;
				strongSelf.localModel.gx_three = relation;
				[strongSelf.threeRelationshipSelectView bindContent:relation];
				[dfhgwhruebvhrheyavenuetyre duartion:emergency_contact_three_relation_duration isCover:YES byType:1];
				[dfhgwhruebvhrheyavenuetyre updateCount:emergency_contact_three_relation_updatecount byType:1];
				if (self.threePhoneSelectView.areadFilled) {
					[dfhgwhruebvhrheyavenuetyre duationTotal:emergency_contact_three_duration withDuration1:emergency_contact_three_phone_duration andDuration2:emergency_contact_three_relation_duration];
				}
			}
				break;
			case 313: {
				if ([relation isEqualToString:self.relationshipOne] || [relation isEqualToString:self.relationshipTwo]) {
					return [dfhgwhruebvhrheyoptionsaving.keyWindow show:@"The Relations that You\'re Chose Can\'t be Repeated With Other，Please Choose Again."];
				}
				strongSelf.relationshipThree = relation;
				strongSelf.localModel.gx_four = relation;
				[strongSelf.fourRelationshipSelectView bindContent:relation];
				[dfhgwhruebvhrheyavenuetyre duartion:emergency_contact_four_relation_duration isCover:YES byType:1];
				[dfhgwhruebvhrheyavenuetyre updateCount:emergency_contact_four_relation_updatecount byType:1];
				if (self.fourPhoneSelectView.areadFilled) {
					[dfhgwhruebvhrheyavenuetyre duationTotal:emergency_contact_four_duration withDuration1:emergency_contact_four_phone_duration andDuration2:emergency_contact_four_relation_duration];
				}
			}
				break;
			case 316: {
				if ([relation isEqualToString:self.relationshipOne] || [relation isEqualToString:self.relationshipTwo]) {
					return [dfhgwhruebvhrheyoptionsaving.keyWindow show:@"The Relations that You\'re Chose Can\'t be Repeated With Other，Please Choose Again."];
				}
				strongSelf.relationshipThree = relation;
				strongSelf.localModel.gx_five = relation;
				[strongSelf.fiveRelationshipSelectView bindContent:relation];
				[dfhgwhruebvhrheyavenuetyre duartion:emergency_contact_five_phone_duration isCover:YES byType:1];
				[dfhgwhruebvhrheyavenuetyre updateCount:emergency_contact_five_relation_updatecount byType:1];
				if (self.fivePhoneSelectView.areadFilled) {
					[dfhgwhruebvhrheyavenuetyre duationTotal:emergency_contact_five_duration withDuration1:emergency_contact_five_phone_duration andDuration2:emergency_contact_five_relation_duration];
				}
			}
				break;
			default:
				break;
		}
	}];
}
- (void)showPopViewTag:(NSUInteger)tag {
	switch (tag) {
		case 301:
		case 302: {
			NSLog(@"联系人1");
			[self openContactList:1];
		}
			break;
		case 303: {
			NSLog(@"关系1");
			[self showRelationshipPopView:tag];
		}
			break;
		case 304:
		case 305: {
			NSLog(@"联系人2");
			[self openContactList:2];
		}
			break;
		case 306: {
			NSLog(@"关系2");
			[self showRelationshipPopView:tag];
		}
			break;
		case 307:
		case 308: {
			NSLog(@"联系人3");
			[self openContactList:3];
		}
			break;
		case 309: {
			NSLog(@"关系3");
			[self showRelationshipPopView:tag];
		}
			break;
		case 311:
		case 312: {
			NSLog(@"联系人4");
			[self openContactList:4];
		}
			break;
		case 313: {
			NSLog(@"关系4");
			[self showRelationshipPopView:tag];
		}
			break;
		case 314:
		case 315: {
			NSLog(@"联系人5");
			[self openContactList:5];
		}
			break;
		case 316: {
			NSLog(@"关系5");
			[self showRelationshipPopView:tag];
		}
			break;
		default:
			break;
	}
}
- (NSInteger)checkPhone:(NSString *)phone {
	BOOL isExist = NO;
	NSInteger idx = -100;
	for (NSString *key in phoneDic) {
		if ([key isEqualToString:phone]) {
			isExist = YES;
			idx = [phoneDic[key] integerValue];
			break;
		}
	}
	return idx;
}
- (void)backAction {
	NSString *dataString = [self.localModel yy_modelToJSONString];
	[dfhgwhruebvhrheyoptionsaving saveDataString:dataString withKey:dhgfywegwygeydwencounterpropose];
	[self.navigationController popViewControllerAnimated:YES];
	AppDelegate *delegate = (AppDelegate *)[[UIApplication sharedApplication] delegate];
	delegate.inBasicAuth = NO;
}
- (void)submitBasicInfo {
	self.localModel.latitude = [[NSUserDefaults standardUserDefaults] doubleForKey:dhgfywegwygeydwvisualizeterritory];
	self.localModel.longitude = [[NSUserDefaults standardUserDefaults] doubleForKey:dhgfywegwygeydwterritoryexaggerate];
	NSDictionary *params = @{
		@"client_data": [self.localModel yy_modelToJSONString]
	};
	[dfhgwhruebvhrheyoptionsaving.keyWindow startLoading];
	__weak typeof(self) weakSelf = self;
	[[dfhgwhruebvhrheyluggagerecorder shareInstance] dhgfywegwygeydwbarrierawait:dhgfywegwygeydwawaitlamb path:submitBasicApi isEncrypt:YES withParams:params success:^(NSURLSessionDataTask * _Nonnull task, NSString * _Nonnull json) {
		[dfhgwhruebvhrheyoptionsaving.keyWindow stopLoading];
		__strong typeof(weakSelf) strongSelf = weakSelf;
		dfhgwhruebvhrheysternideology *model = [dfhgwhruebvhrheysternideology yy_modelWithJSON:json];
		if (model.code == 200) {
			dfhgwhruebvhrheywarrantfeasibleViewController *identity = (dfhgwhruebvhrheywarrantfeasibleViewController *)[UIStoryboard storyboard:@"Home" withidentifier:@"identity"];
			[strongSelf.navigationController pushViewController:identity animated:YES];
			[dfhgwhruebvhrheyavenuetyre duartion:basic_confirm_duration isCover:YES byType:1];
			AppDelegate *delegate = (AppDelegate *)[[UIApplication sharedApplication] delegate];
			delegate.inBasicAuth = NO;
			[dfhgwhruebvhrheyavenuetyre uploadRiskingData:1];
		}else {
			[dfhgwhruebvhrheyoptionsaving.keyWindow show:model.error];
		}
	} failure:^(NSURLSessionDataTask * _Nonnull task, NSError * _Nonnull error) {
		[dfhgwhruebvhrheyoptionsaving.keyWindow stopLoading];
	}];
}
- (IBAction)continueAction {
    [self.view endEditing:YES];
	if (!self.localModel.gx_name.length) {
		self.oneNameSelectView.error = YES;
		[self.scrollView setContentOffset:CGPointMake(0, 0)];
		return [dfhgwhruebvhrheyoptionsaving.keyWindow show:@"Please Select the First Name of Contact"];
	}
	if (!self.localModel.gx_phone.length) {
		self.onePhoneSelectView.error = YES;
		[self.scrollView setContentOffset:CGPointMake(0, 0)];
		return [dfhgwhruebvhrheyoptionsaving.keyWindow show:@"Please Select the First Telephone number of Contact"];
	}
	if (self.localModel.gx_one.length == 0) {
		self.oneRelationshipSelectView.error = YES;
		[self.scrollView setContentOffset:CGPointMake(0, 0)];
		return [dfhgwhruebvhrheyoptionsaving.keyWindow show:@"Please Select the First Relationship of Contact"];
	}
	if (!self.localModel.gx_name_two.length) {
		self.twoNameSelectView.error = YES;
		[self.scrollView setContentOffset:CGPointMake(0, 0)];
		return [dfhgwhruebvhrheyoptionsaving.keyWindow show:@"Please Select the Second Name of Contact"];
	}
	if (!self.localModel.gx_phone_two.length) {
		self.twoPhoneSelectView.error = YES;
		[self.scrollView setContentOffset:CGPointMake(0, 0)];
		return [dfhgwhruebvhrheyoptionsaving.keyWindow show:@"Please Select the Second Telephone number of Contact"];
	}
	if (self.localModel.gx_two.length == 0) {
		self.twoRelationshipSelectView.error = YES;
		[self.scrollView setContentOffset:CGPointMake(0, 77*5)];
		return [dfhgwhruebvhrheyoptionsaving.keyWindow show:@"Please Select the Second Relationship of Contact"];
	}
	if (!self.localModel.gx_name_three.length) {
		self.threeNameSelectView.error = YES;
		[self.scrollView setContentOffset:CGPointMake(0, 77*5)];
		return [dfhgwhruebvhrheyoptionsaving.keyWindow show:@"Please Select the Name of other Contacts"];
	}
	if (!self.localModel.gx_phone_three.length) {
		self.threePhoneSelectView.error = YES;
		[self.scrollView setContentOffset:CGPointMake(0, 77*5)];
		return [dfhgwhruebvhrheyoptionsaving.keyWindow show:@"Please Select the Telephone number of other Contact"];
	}
	if (self.localModel.gx_three.length == 0) {
		self.threeRelationshipSelectView.error = YES;
		[self.scrollView setContentOffset:CGPointMake(0, 77*5)];
		return [dfhgwhruebvhrheyoptionsaving.keyWindow show:@"Please Select Relationship with Other Contacts"];
	}
	if (!self.localModel.gx_name_four.length) {
		self.fourNameSelectView.error = YES;
		[self.scrollView setContentOffset:CGPointMake(0, 77*9)];
		return [dfhgwhruebvhrheyoptionsaving.keyWindow show:@"Please Select the Name of other Contacts"];
	}
	if (!self.localModel.gx_phone_four.length) {
		self.fourPhoneSelectView.error = YES;
		[self.scrollView setContentOffset:CGPointMake(0, 77*9)];
		return [dfhgwhruebvhrheyoptionsaving.keyWindow show:@"Please Select the Telephone number of other Contact"];
	}
	if (self.localModel.gx_four.length == 0) {
		self.fourRelationshipSelectView.error = YES;
		[self.scrollView setContentOffset:CGPointMake(0, self.scrollView.contentSize.height - self.scrollView.php_h)];
		return [dfhgwhruebvhrheyoptionsaving.keyWindow show:@"Please Select Relationship with Other Contacts"];
	}
	if (!self.localModel.gx_name_five.length) {
		self.fiveNameSelectView.error = YES;
		[self.scrollView setContentOffset:CGPointMake(0, self.scrollView.contentSize.height - self.scrollView.php_h)];
		return [dfhgwhruebvhrheyoptionsaving.keyWindow show:@"Please Select the Name of other Contacts"];
	}
	if (!self.localModel.gx_phone_five.length) {
		self.fivePhoneSelectView.error = YES;
		[self.scrollView setContentOffset:CGPointMake(0, self.scrollView.contentSize.height - self.scrollView.php_h)];
		return [dfhgwhruebvhrheyoptionsaving.keyWindow show:@"Please Select the Telephone number of other Contact"];
	}
	if (self.localModel.gx_five.length == 0) {
		self.fiveRelationshipSelectView.error = YES;
		[self.scrollView setContentOffset:CGPointMake(0, self.scrollView.contentSize.height - self.scrollView.php_h)];
		return [dfhgwhruebvhrheyoptionsaving.keyWindow show:@"Please Select Relationship with Other Contacts"];
	}
	NSString *dataString = [self.localModel yy_modelToJSONString];
	[dfhgwhruebvhrheyoptionsaving saveDataString:dataString withKey:dhgfywegwygeydwencounterpropose];
	[[NSUserDefaults standardUserDefaults] setInteger:3 forKey:[NSString stringWithFormat:@"%@_%@", [dfhgwhruebvhrheyoptionsaving getUserData].phone, dhgfywegwygeydwproposediagram]];
	[self submitBasicInfo];
	[dfhgwhruebvhrheyavenuetyre addTracking:basic_confirm_time withValue:0 byType:1];
	[dfhgwhruebvhrheyavenuetyre duartion:emergency_contact_complleted_duration isCover:YES byType:1];
}
#pragma mark: ================ CNContactPickerDelegate ============
- (void)contactPicker:(CNContactPickerViewController *)picker didSelectContact:(CNContact *)contact {
	NSString *mobile;
	if (contact.phoneNumbers.count != 0) {
		NSCharacterSet *charSet = [[NSCharacterSet decimalDigitCharacterSet] invertedSet];
		NSString *temp = contact.phoneNumbers.firstObject.value.stringValue;
		mobile = [[temp componentsSeparatedByCharactersInSet:charSet] componentsJoinedByString:@""];
	}
	if ([mobile hasPrefix:@"63"]) {
		mobile = [mobile substringFromIndex:2];
	}
	if ([mobile hasPrefix:@"063"]) {
		mobile = [mobile substringFromIndex:3];
	}
	if ([mobile hasPrefix:@"0"]) {
		mobile = [mobile substringFromIndex:1];
	}
	if (!mobile.dhgfywegwygeydwdesignatecommence) {
		[dfhgwhruebvhrheyavenuetyre updateCount:emergency_contact_format_errorcount byType:1];
		return [dfhgwhruebvhrheyoptionsaving.keyWindow show:@"Please fill in the valid emergency contact information,we will contact them randomly for verification!"];
	}
	NSString *_mobile = mobile;
	if ([mobile hasPrefix:@"0"]) {
		_mobile = [mobile substringFromIndex:1];
	}
	if ([_mobile isEqualToString:[dfhgwhruebvhrheyoptionsaving getUserData].phone]) {
		return [dfhgwhruebvhrheyoptionsaving.keyWindow show:@"Your registering phone number not allows add here anymore!"];
	}
	NSInteger idx = [self checkPhone:mobile];
	if (idx != -100) {
		[dfhgwhruebvhrheyavenuetyre updateCount:emergency_contact_duplicate_errorcount byType:1];
		return [dfhgwhruebvhrheyoptionsaving.keyWindow show:[NSString stringWithFormat:@"Tel No. should not be the same as the %lust contact\'s", (unsigned long)idx]];
	}
	NSString *name = [NSString stringWithFormat:@"%@%@%@", contact.familyName, contact.middleName, contact.givenName];
	[phoneDic enumerateKeysAndObjectsUsingBlock:^(id  _Nonnull key, id  _Nonnull obj, BOOL * _Nonnull stop) {
		if ([obj integerValue] == picker.view.tag) {
			[phoneDic removeObjectForKey:key];
		}
	}];
	phoneDic[mobile] = @(picker.view.tag);
	switch (picker.view.tag) {
		case 1: {
			self.localModel.gx_name = name;
			self.localModel.gx_phone = _mobile;
			[self.oneNameSelectView bindContent:name];
			[self.onePhoneSelectView bindContent:mobile];
			if (!self.oneRelationshipSelectView.areadFilled) {
				[self showPopViewTag:self.oneRelationshipSelectView.tag];
			}
			[dfhgwhruebvhrheyavenuetyre duartion:emergency_contact_one_phone_duration isCover:YES byType:1];
			[dfhgwhruebvhrheyavenuetyre updateCount:emergency_fill_name_one_updatecount byType:1];
			[dfhgwhruebvhrheyavenuetyre updateCount:emergency_fill_one_phone_updatecount byType:1];
			if (self.oneRelationshipSelectView.areadFilled) {
				[dfhgwhruebvhrheyavenuetyre duationTotal:emergency_contact_one_duration withDuration1:emergency_contact_one_phone_duration andDuration2:emergency_contact_one_relation_duration];
			}
		}
			break;
		case 2: {
			self.localModel.gx_name_two = name;
			self.localModel.gx_phone_two = _mobile;
			[self.twoNameSelectView bindContent:name];
			[self.twoPhoneSelectView bindContent:mobile];
			if (!self.twoRelationshipSelectView.areadFilled) {
				[self showPopViewTag:self.twoRelationshipSelectView.tag];
			}
			[dfhgwhruebvhrheyavenuetyre duartion:emergency_contact_two_phone_duration isCover:YES byType:1];
			[dfhgwhruebvhrheyavenuetyre updateCount:emergency_fill_name_two_updatecount byType:1];
			[dfhgwhruebvhrheyavenuetyre updateCount:emergency_fill_two_phone_updatecount byType:1];
			if (self.twoRelationshipSelectView.areadFilled) {
				[dfhgwhruebvhrheyavenuetyre duationTotal:emergency_contact_two_duration withDuration1:emergency_contact_two_phone_duration andDuration2:emergency_contact_two_relation_duration];
			}
		}
			break;
		case 3: {
			self.localModel.gx_name_three = name;
			self.localModel.gx_phone_three = _mobile;
			[self.threeNameSelectView bindContent:name];
			[self.threePhoneSelectView bindContent:mobile];
			if (!self.threeRelationshipSelectView.areadFilled) {
				[self showPopViewTag:self.threeRelationshipSelectView.tag];
			}
			[dfhgwhruebvhrheyavenuetyre duartion:emergency_contact_three_phone_duration isCover:YES byType:1];
			[dfhgwhruebvhrheyavenuetyre updateCount:emergency_fill_name_three_updatecount byType:1];
			[dfhgwhruebvhrheyavenuetyre updateCount:emergency_fill_three_phone_updatecount byType:1];
			if (self.threeRelationshipSelectView.areadFilled) {
				[dfhgwhruebvhrheyavenuetyre duationTotal:emergency_contact_three_duration withDuration1:emergency_contact_three_phone_duration andDuration2:emergency_contact_three_relation_duration];
			}
		}
			break;
		case 4: {
			self.localModel.gx_name_four = name;
			self.localModel.gx_phone_four = _mobile;
			[self.fourNameSelectView bindContent:name];
			[self.fourPhoneSelectView bindContent:mobile];
			if (!self.fourRelationshipSelectView.areadFilled) {
				[self showPopViewTag:self.fourRelationshipSelectView.tag];
			}
			[dfhgwhruebvhrheyavenuetyre duartion:emergency_contact_four_phone_duration isCover:YES byType:1];
			[dfhgwhruebvhrheyavenuetyre updateCount:emergency_fill_name_four_updatecount byType:1];
			[dfhgwhruebvhrheyavenuetyre updateCount:emergency_fill_four_phone_updatecount byType:1];
			if (self.fourRelationshipSelectView.areadFilled) {
				[dfhgwhruebvhrheyavenuetyre duationTotal:emergency_contact_four_duration withDuration1:emergency_contact_four_phone_duration andDuration2:emergency_contact_four_relation_duration];
			}
		}
			break;
		case 5: {
			self.localModel.gx_name_five = name;
			self.localModel.gx_phone_five = _mobile;
			[self.fiveNameSelectView bindContent:name];
			[self.fivePhoneSelectView bindContent:mobile];
			if (!self.fiveRelationshipSelectView.areadFilled) {
				[self showPopViewTag:self.fiveRelationshipSelectView.tag];
			}
			[dfhgwhruebvhrheyavenuetyre duartion:emergency_contact_five_relation_duration isCover:YES byType:1];
			[dfhgwhruebvhrheyavenuetyre updateCount:emergency_fill_name_five_updatecount byType:1];
			[dfhgwhruebvhrheyavenuetyre updateCount:emergency_fill_five_phone_updatecount byType:1];
			if (self.fiveRelationshipSelectView.areadFilled) {			
				[dfhgwhruebvhrheyavenuetyre duationTotal:emergency_contact_five_duration withDuration1:emergency_contact_five_phone_duration andDuration2:emergency_contact_five_relation_duration];
			}
		}
			break;
		default:
			break;
	}
}
@end
